<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<meta name="layout" content="main" />
		<title>Użytkownik</title>
	</head>
	<body>

		<div class="nav">
            <g:ifAllGranted role="ROLE_ADMIN">
                <span class="menuButton"><g:link class="list" action="list">Lista użytkowników</g:link></span>
                <span class="menuButton"><g:link class="create" action="create">Nowy użytkownik</g:link></span>
            </g:ifAllGranted>
		</div>

		<div class="body">
			<h1>Użytkownik ${person}</h1>
			<g:if test="${flash.message}">
			<div class="message">${flash.message}</div>
			</g:if>
			<div class="dialog">
				<table>
				<tbody>

                    <tr class="prop">
						<td valign="top" class="name">Imię:</td>
						<td valign="top" class="value">${person.firstName?.encodeAsHTML()}</td>
					</tr>

					<tr class="prop">
						<td valign="top" class="name">Nazwisko:</td>
						<td valign="top" class="value">${person.lastName?.encodeAsHTML()}</td>
					</tr>

                    <g:ifAllGranted role="ROLE_ADMIN">
                        <tr class="prop">
                            <td valign="top" class="name">Konto włączone:</td>
                            <td valign="top" class="value">${person.enabled}</td>
                        </tr>
                    </g:ifAllGranted>

					<tr class="prop">
						<td valign="top" class="name">Login/Email:</td>
						<td valign="top" class="value">${person.username?.encodeAsHTML()}</td>
					</tr>

                    <tr class="prop">
                        <td valign="top" class="name">Ulica:</td>
                        <td valign="top" class="value">${person?.street?.encodeAsHTML()}</td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">Miasto:</td>
                        <td valign="top" class="value">${person?.city?.encodeAsHTML()}</td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">Kod pocztowy:</td>
                        <td valign="top" class="value">${person?.zipCode?.encodeAsHTML()}</td>
                    </tr>

                    <g:ifAllGranted role="ROLE_ADMIN">
                        <tr class="prop">
                            <td valign="top" class="name">Role:</td>
                            <td valign="top" class="value">
                                <ul>
                                <g:collect in="${person.authorities}" expr="${it.authority}">
                                    <li>${it?.substring(5)?.toLowerCase()}</li>
                                </g:collect>
                                </ul>
                            </td>
                        </tr>
                    </g:ifAllGranted>

				</tbody>
				</table>
			</div>

			<div class="buttons">
				<g:form>
					<input type="hidden" name="id" value="${person.id}" />
					<span class="button"><g:actionSubmit class="edit" value="Edytuj" action="edit"/></span>
					<g:ifAllGranted role="ROLE_ADMIN">
                        <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Usuń" action="delete"/></span>
                    </g:ifAllGranted>
				</g:form>
			</div>

		</div>
	</body>
</html>

